import numpy as np
from PIL import Image

Image.MAX_IMAGE_PIXELS = None

from siamese import Siamese

if __name__ == "__main__":
    model = Siamese()

    while True:
        image_1 = input('Input image_1 filename:')
        try:
            image_1 = Image.open(image_1)

            # 设置裁剪区域 (left, upper, right, lower)
            # left = 5000
            # upper = 5000
            # right = left + 1000
            # lower = upper + 1000
            # image_1 = image_1.crop((left, upper, right, lower))
        except Exception as e:
            print('Image_1 Open Error! Try again!', e)
            continue

        image_2 = input('Input image_2 filename:')
        try:
            image_2 = Image.open(image_2)
        except Exception as e:
            print('Image_2 Open Error! Try again!', e)
            continue
        probability = model.detect_image(image_1, image_2)
        print(probability)
